#include <iostream>
#include <set>
#include <string>
using namespace std;
#define DEBUG
const int N=110;
//字母 每个文章(下标) 出现的次数
set<string> A, B, jiao, bing;
int n, m;
string word;
inline void check(string& str)
{
    for(char& ch:str)
    {
        if('A' <= ch && ch <= 'Z')
            ch += 32;
    }
}

signed main()
{
    #ifdef DEBUG
        freopen("../in.txt", "r", stdin);
        freopen("../out.txt", "w", stdout);
    #endif

    cin >> n >> m; //第一篇文章单词数 第二篇文章单词数
    for(int i=1; i<=n; i++)
    {
        cin >> word;
        check(word);
        A.insert(word);
        bing.insert(word);
    }

    for(int i=1; i<=m; i++)
    {
        cin >> word;
        check(word);
        B.insert(word);
        bing.insert(word);
    }

    
    for(auto it=A.begin(); it!=A.end(); it++)
    {    if(B.count(*it)) jiao.insert(*it);
    }
    printf("%d\n%d\n", jiao.size(), bing.size());
    return 0;
}